package cn.leelei.hibernate.entity;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * 
 * @author Nike
 *
 */
//添加注解实体类
@Entity
//添加注解表表名为User
@Table(name="Role")
public class Role {
	//映射主键
	@Id
	//主键的生成策略
	//自增长IDENTITY
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Integer id;//用户表的id 字段
	@Column(name="UserName")//普通列名
	private String UserName;//用户表的UserName 字段
	@Column(name="PassWord")//普通列名
	private String PassWord;//用户表的PassWord 字段
	@Column(name="Address")//普通列名
	private String Address;//用户表的Address 字段
	
	//级联保存CascadeType.PERSIST, 级联删除CascadeType.REMOVE ；级联 级联解决懒加载fetch = FetchType.EAGER
    @OneToMany(cascade={CascadeType.PERSIST,CascadeType.REMOVE},fetch = FetchType.EAGER)//一对多
    @JoinColumn(name="Role_id")
	private Set<Email> emails;
	
    
    
	public Set<Email> getEmails() {
		return emails;
	}
	public void setEmails(Set<Email> emails) {
		this.emails = emails;
	}
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getUserName() {
		return UserName;
	}
	public void setUserName(String userName) {
		UserName = userName;
	}
	public String getPassWord() {
		return PassWord;
	}
	public void setPassWord(String passWord) {
		PassWord = passWord;
	}
	public String getAddress() {
		return Address;
	}
	public void setAddress(String address) {
		Address = address;
	}
	
	public Role() {
		super();
		
	}
	
    
}
